//
//  DownTableViewCell.m
//  Cook
//
//  Created by 0.0 on 15-4-22.
//  Copyright (c) 2015年 dingjun. All rights reserved.
//

#import "DownTableViewCell.h"

@implementation DownTableViewCell

- (void)dealloc
{
    [_videoImageView release];
    [_videoPlayView release];
    [_progress release];
    [_videoName release];
    [_videoDownStateNum release];
    
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        CGAdapter _myAd = [AdapterModel getCGAdapter];
        
        self.frame = CGRectMake(0, 0, 375 * _myAd.sWidth, 100);// VideoDownController里的tableviewRow的高度是100
        
        self.videoImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 80 * _myAd.sWidth, 80)];
        self.videoPlayView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 40 * _myAd.sWidth, 40)];
        self.videoPlayView.center = _videoImageView.center;
        self.videoPlayView.backgroundColor = [UIColor whiteColor];
        self.videoPlayView.alpha = 0.7f;
        self.videoPlayView.layer.cornerRadius = _videoPlayView.frame.size.width / 2;
        NSString *path = [[NSBundle mainBundle] pathForResource:@"play" ofType:@"png"];
        [self.videoPlayView setImage:[UIImage imageWithContentsOfFile:path]];

        self.videoName = [[UILabel alloc] initWithFrame:CGRectMake(_videoImageView.frame.origin.x + _videoImageView.frame.size.width + 10, _videoImageView.frame.origin.y, 150 * _myAd.sWidth, 40)];
        self.videoName.font = [UIFont systemFontOfSize:20.0f];
        

        self.progress = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleDefault];
        self.progress.frame = CGRectMake(_videoName.frame.origin.x, _videoName.frame.origin.y + _videoName.frame.size.height + 10, (self.frame.size.width - 10 - _videoImageView.frame.size.width - 10 - 80) * _myAd.sWidth, 20);
        
        self.videoDownStateNum = [[UILabel alloc] initWithFrame:CGRectMake(_videoName.frame.origin.x + _progress.frame.size.width, _videoName.frame.origin.y + _videoName.frame.size.height + 5, 80 * _myAd.sWidth, 40)];
        self.videoDownStateNum.font = [UIFont systemFontOfSize:15.0f];
        
        
        [self.contentView addSubview:_videoImageView];
        [self.contentView addSubview:_videoPlayView];
        [self.contentView addSubview:_videoName];
        [self.contentView addSubview:_videoDownStateNum];
        [self.contentView addSubview:_progress];
//        [self.contentView addSubview:_videoPlayButton];
       
        
        [_videoImageView release];
        [_videoPlayView release];
//        [_videoPlayButton release];
        [_videoName release];
        [_videoDownStateNum release];
    }
    
    return self;
}



- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
